
LinkedList<NxVec3> baum[2];
void TreeBranch(LinkedList<NxVec3>& anfang, LinkedList<NxVec3>& ende, NxVec3 vA, NxVec3 vE) {
	const float s = 0.5f;
	const float u = 0.5f;
	NxVec3 v = vE - vA;
	float m = v.magnitude();

	if(m > 0.05f) {
		float x1 = (10-rand()%21);
		float y1 = (10-rand()%21);
		float z1 = (10-rand()%21);
		NxVec3 r1(x1,y1,z1);
		NxVec3 v1 = (v + r1*u*0.1f*m) * s;
		NxVec3 nA1 = vE;
		NxVec3 nE1 = vE + v1;
		anfang << nA1;
		ende << nE1;
		TreeBranch(anfang, ende, nA1, nE1);

		float x2 = (10-rand()%21);
		float y2 = (10-rand()%21);
		float z2 = (10-rand()%21);
		NxVec3 r2(x2,y2,z2);
		NxVec3 v2 = (v + r2*u*0.1f*m) * s;
		NxVec3 nA2 = vE;
		NxVec3 nE2 = vE + v2;
		anfang << nA2;
		ende << nE2;
		TreeBranch(anfang, ende, nA2, nE2);
	}
}



//draw:
glDisable(GL_LIGHTING);
glPushMatrix();
SurfaceRenderingData srd;
srd.SetColor(0,1,0,1);
Renderer::SetMaterial(srd);
glScalef(3,3,3);
for(int i=0; i<baum[0].Size(); ++i) {
	NxVec3 a = baum[0][i];
	NxVec3 e = baum[1][i];

	float lineW = (e-a).magnitude() * 200;
	glLineWidth(lineW/(a-camera.GetPosition()).magnitude());
	
	glBegin(GL_LINES);
	glVertex3f(a.x, a.y, a.z);
	glVertex3f(e.x, e.y, e.z);
	glEnd();
}
glPopMatrix();
glEnable(GL_LIGHTING);
	

	
//create
baum[0].Clear();
baum[1].Clear();
const float s = 0.1f;
float x = (10-rand()%21)*0.1f*s;
float y = (10-rand()%21)*0.1f*s;
float z = (10-rand()%21)*0.1f*s;
NxVec3 baumA(0,0,0);
NxVec3 baumE(x,y+1,z);
baum[0] << baumA;
baum[1] << baumE;
TreeBranch(baum[0], baum[1], baumA, baumE);


	